for i in range(int(input())):
s, x= [z for z in input().split()]
t= s[:2]
u= s[3:]
x= int(x)
t= int(t)
u= int(u)
v= t*60 + u
y= [0, 70, 140, 210, 280, 350, 601, 671, 741, 811, 881, 951, 1202, 1272, 1342, 1412]
b= set()
for j in range(2880):
if v in y:
b.add(v)
v += x
v %= 1440
print(len(b))
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void seive(bool primes[], int n) {
for (int i = 1; i <= n; i++) {
primes[i] = 1;
}
primes[1] = 0;
primes[0] = 0;
int x = sqrt(n);
for (int i = 2; i <= x; i++) {
if (primes[i] == 1) {
for (int j = i * i; j <= n; j += i) {
primes[j] = 0;
}
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie();
int arr[16]={0,70,140,280,210,350,601,671,741,811,881,951,1202,1272,1342,1412};
int t;
cin >> t;
while (t--){
string s;
int x;
cin >> s >> x;
int c=0;
c+=(int)(s[0]-48)*60*10;
c+=(int)(s[1]-48)*60;
c+=(int)(s[3]-48)*10;
c+=(int)(s[4]-48);
map<int ,int>m;
// cout << c<<endl;
int cnt = 0;
int e=0;
// cout << c;
int y = 10000;
while(y--)
{
// e+=x;
for (int i = 0; i < 16; ++i) {
if(c==arr[i] && m[arr[i]]!=5){
cnt++;
m[arr[i]]=5;
}
}
c+=x;
c=(c%1440);
}
cout << cnt<<endl;
}
}
518. Coin Change 2 | 516. Longest Palindromic Subsequence |
468. Validate IP Address | 450. Delete Node in a BST |
445. Add Two Numbers II | 442. Find All Duplicates in an Array |
437. Path Sum III | 436. Find Right Interval |
435. Non-overlapping Intervals | 406. Queue Reconstruction by Height |
380. Insert Delete GetRandom O(1) | 332. Reconstruct Itinerary |
368. Largest Divisible Subset | 377. Combination Sum IV |
322. Coin Change | 307. Range Sum Query - Mutable |
287. Find the Duplicate Number | 279. Perfect Squares |
275. H-Index II | 274. H-Index |
260. Single Number III | 240. Search a 2D Matrix II |
238. Product of Array Except Self | 229. Majority Element II |
222. Count Complete Tree Nodes | 215. Kth Largest Element in an Array |
198. House Robber | 153. Find Minimum in Rotated Sorted Array |
150. Evaluate Reverse Polish Notation | 144. Binary Tree Preorder Traversal |